package com.seth.myapplication;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.seth.myapplication.bean.Rewords;
import com.seth.myapplication.bean.User;
import com.seth.myapplication.helper.SetStatusTabHeight;
import com.seth.myapplication.surface.AcceptTask;
import com.seth.myapplication.surface.UsrGetTask;
import com.seth.myapplication.surface.UsrSetTask;

/**
 * Created by Seth on 2017/11/21.
 */

public class MyTaskActivity extends FragmentActivity {
    private static final String EXTRA_USER = "com.seth.myapplication.MyTaskAcitivty";
    private static final String EXTRA_FLAG = "com.seth.myapplication.MyTaskAcitivty.flag";
    private FragmentManager fm;
    private User mUser;
    private LinearLayout topStatus;
    private int flag;

    public static Intent newIntent(Context context, User user, int flag) {
        Intent intent = new Intent(context,MyTaskActivity.class);
        intent.putExtra(EXTRA_USER, user);
        intent.putExtra(EXTRA_FLAG,flag);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        setContentView(R.layout.activity_accept);

        Intent i = getIntent();
        mUser = (User) i.getSerializableExtra(EXTRA_USER);
        flag = i.getIntExtra(EXTRA_FLAG,0);
        initView();
        initEvent();
    }

    private void initEvent() {
        new SetStatusTabHeight(topStatus,this).setRelativeLayout();
        Fragment fragment;
        if(flag ==0){
            fragment = UsrGetTask.newInstance(mUser);
        }else{
            fragment = UsrSetTask.newInstance(mUser);
        }
        fm = getSupportFragmentManager();
        // fragment = fm.findFragmentById(R.id.accept_content);
        fm.beginTransaction().add(R.id.accept_content, fragment).commit();
    }
    private void initView() {
        topStatus = (LinearLayout) findViewById(R.id.accept_top_sts);
    }




}
